package com.huawei.updatesdk.service.e;

import android.text.TextUtils;
import com.huawei.fastengine.BuildConfig;
import com.huawei.updatesdk.a.a.b.a.a.a;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public final class b {
    private static final Map<Integer, String> a = new HashMap();
    private static b b = new b();
    private int c;
    private String d;

    static {
        a.put(Integer.valueOf(1), BuildConfig.VERSION_NAME);
        a.put(Integer.valueOf(2), "1.5");
        a.put(Integer.valueOf(3), "1.6");
        a.put(Integer.valueOf(4), "2.0");
        a.put(Integer.valueOf(5), "2.0");
        a.put(Integer.valueOf(6), "2.3");
        a.put(Integer.valueOf(7), "3.0");
        a.put(Integer.valueOf(8), "3.0.5");
        a.put(Integer.valueOf(8), "3.1");
        a.put(Integer.valueOf(9), "4.0");
        a.put(Integer.valueOf(10), "4.1");
        a.put(Integer.valueOf(11), "5.0");
        a.put(Integer.valueOf(12), "5.1");
    }

    private b() {
        this.c = 0;
        this.d = "";
        this.c = d();
        if (this.c == 0) {
            this.c = e();
        }
        this.d = f();
        a.a("EMUISupportUtil", "emuiVersion:" + this.c + ",emuiVersionName:" + this.d);
    }

    public static b a() {
        return b;
    }

    private String a(String str) {
        String str2 = "";
        if (TextUtils.isEmpty(str)) {
            return str2;
        }
        String[] split = str.split("_");
        return split.length == 2 ? split[1] : str2;
    }

    private int d() {
        return com.huawei.updatesdk.a.a.c.a.a.a("ro.build.hw_emui_api_level", 0);
    }

    private int e() {
        Object a = a(com.huawei.updatesdk.a.a.c.a.a.a("ro.build.version.emui", ""));
        if (!TextUtils.isEmpty(a)) {
            for (Entry entry : a.entrySet()) {
                if (a.equals(entry.getValue())) {
                    return ((Integer) entry.getKey()).intValue();
                }
            }
        }
        return 0;
    }

    private String f() {
        String str = (String) a.get(Integer.valueOf(this.c));
        return str == null ? "" : str;
    }

    public int b() {
        return this.c;
    }

    public String c() {
        return this.d;
    }
}
